#include <sourcemod>
#include <sdktools>
#include <adminmenu>
#include <l4d_stocks>

#include "macros.sp"
#include "helpers.sp"

public OnPluginStart()
{
	RegConsoleCmd("menu", show_menu);
}

public Action:show_menu(client, args)
{
	if(!IsValidClient(client))
		return;	

	new Handle:panel = CreatePanel();
	DrawPanelItem(panel, "Choose Team");
	DrawPanelItem(panel, "Display Survivors");
	DrawPanelItem(panel, "Display Infected");
	DrawPanelItem(panel, "Display Spectators");

	if(GetUserFlagBits(client) != 0) //if admin
	{
		DrawPanelItem(panel, "Swap Player");
	}

	if(panel != INVALID_HANDLE)
	{
		SendPanelToClient(panel, client, panel_handler, 20);

		CloseHandle(panel);
	}
}


public panel_handler(Handle:menu, MenuAction:action, client, choice)
{
	if (action == MenuAction_Select)
	{
		if(choice == 1)
		{
			ClientCommand(client, "teams");
		}
		else if(choice == 2)
		{
			ClientCommand(client, "players surv");
		}
		else if(choice == 3)
		{
			ClientCommand(client, "players inf");
		}
		else if(choice == 4)
		{
			ClientCommand(client, "players spec");
		}
		else if(choice == 5)
		{
			if(GetUserFlagBits(client) != 0)
				ClientCommand(client, "swap");
		}

	}	
}
